//
//  ViewController.m
//  CalenderDemo
//
//  Created by GZMLUser on 14-11-6.
//  Copyright (c) 2014年 GZMLUser. All rights reserved.
//

#import "ViewController.h"
#import "calenderView.h"

@interface ViewController () <calendarDayClickedDelegate>
@property (nonatomic ,strong)NSDate *curDate;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.curDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"dd/MM/yyyy --- HH:mm"];
    self.view.backgroundColor = [UIColor grayColor];
    
    
    UIButton *Button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    Button2.frame = CGRectMake(50, 100, 100, 50);
    [Button2 setTitle:@"底部弹出日历" forState:UIControlStateNormal];
    [Button2 addTarget:self action:@selector(sureButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:Button2];

    UIButton *Button1 = [UIButton buttonWithType:UIButtonTypeSystem];
    Button1.frame = CGRectMake(150, 100, 100, 50);
    [Button1 setTitle:@"中间弹出日历" forState:UIControlStateNormal];
    [Button1 addTarget:self action:@selector(popCalendarView) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:Button1];
}

- (void)sureButtonClicked // 底部弹出
{
    calenderView *calendar = [[calenderView alloc]initWithAnimateTye:Bottom andDate:self.curDate addToSuperView:self.view];
 
    calendar.delegate = self;
    [self.view addSubview:calendar];
}


- (void)popCalendarView // 中间弹出
{
    calenderView *calendar = [[calenderView alloc]initWithAnimateTye:Popping andDate:self.curDate addToSuperView:self.view];
    
    calendar.delegate = self;
    [self.view addSubview:calendar];
}


#pragma mark 代理方法
- (void)calendarDayClicked:(NSDate *)date // 点击了日期
{
    NSLog(@"ss:%@",date);
}

- (void)calendarViewDoneClicked:(calenderView *)calenderView // 点击了确定按钮
{
    NSDate *date = calenderView.currentDate;
    NSLog(@"ssaa:%@",date);
}
@end
